package com.chony.apps.gps_example;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MiItemizedOverlay extends ItemizedOverlay<OverlayItem> {
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context context;
	public void addLocalizacion(double lat, double lon, String etiqueta){
		int lt = (int) (lat*1E6);
		int ln = (int) (lon*1E6);
		GeoPoint punto = new GeoPoint(lt,ln);
		OverlayItem item = new OverlayItem(punto, etiqueta, null);
		mOverlays.add(item);
		populate();
	}
	public void clear(){
		mOverlays.clear();
		populate();
	}

protected OverlayItem createItem(int i) {
	 Auto-generated method stub
	return mOverlays.get(i);
}

	public int size() {
		 Auto-generated method stub
		return mOverlays.size();
	}
public MiItemizedOverlay(Context context, Drawable defaultMarker) {
	 Auto-generated constructor stub
	super(boundCenterBottom(defaultMarker));
	this.context = context;
}

public boolean onTap(int index) {
	 Auto-generated method stub
	String etiqueta = mOverlays.get(index).getTitle();
	Toast.makeText(context, etiqueta, Toast.LENGTH_LONG).show();
	return false;
}
}
